import asyncio

def get_event_loop() -> asyncio.AbstractEventLoop:
    try:
        # 如果有事件循环
        loop = asyncio.get_event_loop()
    except RuntimeError:
        # 在子线程中
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
    return loop